package cn.sdormitory.evaluation.service.impl;

import cn.sdormitory.common.utils.DataRoleUtil;
import cn.sdormitory.evaluation.dao.EvaluationReportDao;
import cn.sdormitory.evaluation.service.EvaluationReportService;
import cn.sdormitory.evaluation.vo.EvaluationReportVO;
import cn.sdormitory.exam.vo.ExamInfoVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EvaluationReportServiceImpl implements EvaluationReportService {
    @Resource
    EvaluationReportDao evaluationReportDao;
    @Resource
    DataRoleUtil dataRoleUtil;

    @Override
    public IPage<EvaluationReportVO> pageList(EvaluationReportVO vo) {
        List<String> userList = dataRoleUtil.getDeptSubordinateUserList();
        if(userList.size()>0){
            vo.setUserList(userList);
        }
        int count =  evaluationReportDao.selectClassInfoCount(vo);
        int startNum=(vo.getPageNum()-1)*vo.getPageSize();
        vo.setPageNum(startNum);
        List<EvaluationReportVO> examInfoList =  evaluationReportDao.selectClassInfo(vo);
        IPage<EvaluationReportVO> page = new Page<>();
        page.setTotal(count);
        page.setRecords(examInfoList);
        return page;
    }
}
